<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>修改密码</title>
		<link rel="stylesheet" type="text/css" href="${BASE_PATH}/static/lib/layui/css/layui.css" />
	</head>

	<body>
		<form class="layui-form" action="" style="margin: 10px 10px 0 10px;">
			<div class="layui-form-item">
				<label class="layui-form-label">原始密码</label>
				<div class="layui-input-inline">
					<input id="oldPd" type="password" name="oldPd" lay-verify="pass" placeholder="请输入原始密码" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">新密码</label>
				<div class="layui-input-inline">
					<input id="newPd" type="password" name="newPd" lay-verify="pass" placeholder="请输入新密码" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">确认密码</label>
				<div class="layui-input-inline">
					<input id="newPd1" type="password" name="newPd1" lay-verify="pass" placeholder="请输入新密码" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<a class="layui-btn" lay-submit="" lay-filter="demo1"><i class="layui-icon">&#x1005;</i>保存</a>
				</div>
			</div>
		</form>

	</body>
	<script type="text/javascript" src="${BASE_PATH}/static/lib/layui/layui.js"></script>
	<script>
		layui.use(['form', 'layedit', 'laydate', 'jquery','layer'], function() {
			var form = layui.form,
				layer = layui.layer;
			var $ = layui.jquery;
			var layer = layui.layer;

			//自定义验证规则
			form.verify({
				title: function(value) {
					if(value.length < 5) {
						return '标题至少得5个字符啊';
					}
				},
				pass: [/(.+){6,12}$/, '密码必须6到12位'],
				content: function(value) {
					layedit.sync(editIndex);
				}
			});

			//监听提交
			form.on('submit(demo1)', function(data) {
				var oldPd = $("#oldPd").val();
				var newPd = $("#newPd").val();
				var newPd1 = $("#newPd1").val();
				if(newPd != newPd1){
					layer.msg("两次密码输入不一致，请重新输入")
					return;
				}else{
					$.ajax({
						type:'POST',
						url:'${BASE_PATH}/admin/manage/ajax_user_edit_pd',
						data:data.field,
						async:true,
						success:function(res){
						console.dir(11)
							if(res.code == 400 && res.success == false){
								layer.msg(res.msg)
							}else if(res.code == 200 && res.success == true){
								layer.msg(res.msg)
								 window.location.href="${BASE_PATH}/admin/logout"; 
							}else if(res.code == 401 && res.success == false){
								layer.msg(res.msg)
							}else if(res.code == 402 && res.success == false){
								layer.msg(res.msg)	
							}
						}
					})
				}
			});

		});
	</script>

</html>